package com.cl.mybatis.learn.day07;

import java.util.Collection;
import java.util.Properties;

import org.apache.ibatis.reflection.factory.DefaultObjectFactory;

public class ExampleObjectFactory extends DefaultObjectFactory {
    @Override
    public Object create(Class type) {
        
        if (User.class == type) {
            // 创建结果对象
            User user = (User) super.create(type);
            // 通过复杂的计算，设置addr的值
            user.setAddr("CHINA");
            return user;
            
        }
        return super.create(type);
    }
    
    // public Object create(Class type, List<Class> constructorArgTypes,
    // List<Object> constructorArgs) {
    // return super.create(type, constructorArgTypes, constructorArgs);
    // }
    
    @Override
    public void setProperties(Properties properties) {
        super.setProperties(properties);
    }
    
    @Override
    public <T> boolean isCollection(Class<T> type) {
        return Collection.class.isAssignableFrom(type);
    }
}